//
//  SingleDefineHeader.h
//  customer
//
//  Created by Holothurian on 2018/10/19.
//  Copyright © 2018年 yinlong. All rights reserved.
//

#ifndef SingleDefineHeader_h
#define SingleDefineHeader_h

//联系客服
#define kContactPhone   @"18516388069"
/*
 商家号：1518255671
 key：us37kna3gyfFlz1zpXWResh2TK2F3fEt
 AppID:wx5d990ac413cb31de
 AppSecret:dd9ffdc7fe99fa52ea94be2d1125eec5
 */
#define WXOpenID        @"wx5d990ac413cb31de"
#define WXAppKey        @"us37kna3gyfFlz1zpXWResh2TK2F3fEt"
#define WXAppSecret     @"dd9ffdc7fe99fa52ea94be2d1125eec5"
#define WXBuinessID     @"1518255671"


#define WXSnsOauth2_Authorization_Code @"https://api.weixin.qq.com/sns/oauth2/access_token?"
#define WXSnsUserInfo   @"https://api.weixin.qq.com/sns/userinfo?"
#define WXSnsRefreshToken  @"https://api.weixin.qq.com/sns/oauth2/refresh_token?"

#define kPostNotificationForRepairOrder @"kPostNotificationForRepairOrder"
#define kRegisterBackgroundNoti @"kRegisterBackgroundNoti"
#define kRegisterFrontNoti @"kRegisterFrontNoti"
#define WeakObj(o) autoreleasepool{} __weak typeof(o) o##Weak = o; //引用self


#define skyGetImage(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]

#ifdef DEBUG
#define SLog(...) NSLog(@"%s 第%d行 \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
#else
#define SLog(...)
#endif

#define kCallThePhone(x)   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",x]]];


/**
 适配相关
 */
#define SCALE_WIDTH(w) ((CGFloat)w/414)*([UIScreen mainScreen].bounds.size.width)
#define SCALE_HEIGHT(h) ((CGFloat)h/736)*([UIScreen mainScreen].bounds.size.height)
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)


/// 判断字符串是否为空
#define k_Is_Empty(s)               (!s || [s isEqual:[NSNull null]] || [s isEqualToString:@""] || [s isEqualToString:@"null"])

/// 屏幕宽度
#define F_DEVICE_W          [UIScreen mainScreen].bounds.size.width
/// 屏幕高度
#define F_DEVICE_H          [UIScreen mainScreen].bounds.size.height

/// NSUserDefaults 读写
#define K_UserDefault_Write(value,key)      [[NSUserDefaults standardUserDefaults] setObject:value forKey:key]

#define K_UserDefault_Read(key)             [[NSUserDefaults standardUserDefaults] objectForKey:key]
/**
 *  清除 NSUserDefaults 保存的指定数据
 */
#define K_UserDefault_Remove(key)                                         \
({                                                                          \
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];       \
[defaults removeObjectForKey:key];                                     \
[defaults synchronize];                                                 \
})

//当前版本
#define Version  [(__bridge NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle())objectForKey:@"CFBundleShortVersionString"]

//对象转成JSONString
#define JSON_STRING_FROM_OBJECT(_OBJ_)  [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:_OBJ_ options:NSJSONWritingPrettyPrinted error:nil] encoding:NSUTF8StringEncoding]

//************************** 切换tabBar端控制器 **************
/// tabbar 推
#define TAB_PUSH(selfPage,tPage,push)           {[tPage setHidesBottomBarWhenPushed:YES];\
tPage.isPush = push;\
[selfPage.navigationController pushViewController:tPage animated:NO];}

/// controller 推
#define SELF_PUSH(selfPage,tPage,push)        {tPage.isPush = push;\
[selfPage.navigationController pushViewController:tPage animated:YES];}

/// 基本的TabController
#define TAB_BASE                             [(AppDelegate*)[[UIApplication sharedApplication] delegate]homeTabBar]

/// TabController选中第几个
#define TAB_SELECT(index)                 [TAB_BASE setSelectedIndex:index];

/// TabController自动判断跳转回根界面
#define TAB_AUTO_SELECT(idx)             {if([TAB_BASE selectedIndex]!=idx){\
[TAB_BASE setSelectedIndex:idx];\
} else {\
[(UINavigationController*)[[TAB_BASE viewControllers] objectAtIndex:idx] popToRootViewControllerAnimated:YES];\
}}

//block
#define AutoWeakSelf  __weak typeof(self) weakSelf = self;
// RGB颜色
#define RGBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define RGBAColor(r, g, b , a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]

// 判断是否是iPhone X
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
// 状态栏高度
#define STATUS_BAR_HEIGHT (iPhone_XX ? 44.f : 20.f)
// 导航栏高度
#define NAVIGATION_BAR_HEIGHT (iPhone_XX ? 88.f : 64.f)
// tabBar高度
#define TAB_BAR_HEIGHT (iPhone_XX ? (49.f+34.f) : 49.f)

// home indicator
#define HOME_INDICATOR_HEIGHT (iPhone_XX ? 34.f : 0.f)

#define PROPORTION_HEIGHT_IPHONE6 F_DEVICE_H/667
#define PROPORTION_WIDTH_IPHONE6 F_DEVICE_W/375

#define ORIGINAL_MAX_WIDTH 640.0f

#define Font26 [UIFont systemFontOfSize:13]
#define Font28 [UIFont systemFontOfSize:14]
#define Font30 [UIFont systemFontOfSize:15]
#define Font(Size) [UIFont systemFontOfSize:Size]

//判断是否是ipad
#define is_Pad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)

//#define iPhone_XX (iPhoneX||iPHONE_XR||iPhoneXS||iPhone_XSMax)
#define iPhone_XX (([[UIScreen mainScreen]bounds].size.height >= 812 && !is_Pad)?: NO)

#define topPading(a) ((iPhone_XX)?(24+a):(a))
#define bottomPadding(a) ((iPhone_XX)?(34+a):(a))


#define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f)
#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
#define iOS9Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.0f)
#define iOS9_1Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.1f)


#define SHOW_ALERT(_title_,_message_,_cancel_,_btn_,AlertTag) UIAlertView * alert = [[UIAlertView alloc]initWithTitle:_title_ message:_message_ delegate:nil cancelButtonTitle:_cancel_ otherButtonTitles:_btn_, nil];\
alert.delegate = self;\
alert.tag = AlertTag;\
[alert show];\

/*******   日志   ***************/
#if DEBUG
#define NSLog(FORMAT, ...) {\
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];\
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];\
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];\
[dateFormatter setDateFormat:@"HH:mm:ss:SSSSSS"]; \
NSString *str = [dateFormatter stringFromDate:[NSDate date]];\
fprintf(stderr,"[--%s--]*[--%s:%d行--]：%s\n",[str UTF8String],[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);\
}
#else
#define NSLog(FORMAT, ...) nil;
#endif

//数组是否为空
#define kArrayIsEmpty(array)        (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)

#endif /* SingleDefineHeader_h */
